<?php
	
	include('cms.php');
	
	if(isset($_GET['name'])){
		$cat = new Category();
		$cat->name = $_GET['name'];
		
		if(isset($_GET['idcategory']) && !empty($_GET['idcategory'])){
			$cat->cmsCategory_idcategory = $_GET['idcategory'];
		}else{
			$cat->cmsCategory_idcategory = "NULL";
		}
		
		$cat->insert();
	}
	
	$cats = DataLatte::arrayof('Category', "SELECT * FROM cmsCategory");
	
	echo json_encode($cats);
?>